		var selectedEmployeeInfos = null;
		var s_edit_h = 'hidden';
		var s_remove_h = 'hidden';
		var prefix = basepath + "/employee";
		
		$(function() {
			//searchEmployee()
			loadEmployeesTable();
		});
		
		function getEmpNameSel () {
			let employeeNameSel = $("input#cmpName").val()
			// alert('EmployeeNameSel:' + EmployeeNameSel)
			return employeeNameSel
		}
		function getCertNoSel () {
			let certNoSel = $("input#certNo").val()
			// alert('EmployeeNameSel:' + EmployeeNameSel)
			return certNoSel
		}
		function getBankCardNbrSel () {
			let bankCardNbrSel = $("input#bankCardNbr").val()
			// alert('EmployeeNameSel:' + EmployeeNameSel)
			return bankCardNbrSel
		}
		function getMobileSel () {
			let mobileSel = $("input#mobile").val()
			// alert('EmployeeNameSel:' + EmployeeNameSel)
			return mobileSel
		}
		function getAbbrevationSel () {
			let abbrevationSel = $("input#abbrevation").val()
			// alert('EmployeeNameSel:' + EmployeeNameSel)
			return abbrevationSel
		}
		function getEmpStatusSel () {
			let empStatusSel = $("input#empStatus").val()
			// alert('EmployeeNameSel:' + EmployeeNameSel)
			return empStatusSel
		}
		
		function loadEmployeesTable () {
			layui.use('table', function(){
				  var table = layui.table;
				  
				  
				  //第一个实例
				  table.render({
				    elem: '#employeesTable'
				    ,height: 390
				    ,url: prefix + '/queryEmployeeInfos' //数据接口
				    //,page: true //开启分页

				    ,page: true

				  	,where: { //设定异步数据接口的参数
					    key: 'nickname'
					    ,value: 'test'
					    ,empName: getEmpNameSel()
					    ,certNo: getCertNoSel()
					    ,bankCardNbr: getBankCardNbrSel()
					    ,mobile: getMobileSel()
					    ,abbreviation: getAbbrevationSel()
					    ,empStatus: getEmpStatusSel()
					}
				    ,cols: [[ //表头
				      {checkbox: true, fixed: true}
				      ,{field: 'empName', title: '姓名', width:80, sort: true, fixed: 'left'}
				      ,{field: 'abbreviation', title: '所属部门', width:100}
				      ,{field: 'certNo', title: '身份证号', width:200, sort: true}
				      ,{field: 'bankCardNbr', title: '福利卡号', width:150} 
				      ,{field: 'merchantCode', title: '银行卡预留手机号', width:110 }
				      ,{field: '', title: '备注', width:100}
				      ,{field: 'empStatus', title: '卡状态', width:100}
				      ,{field:'right', title: '操作', width:250,toolbar:"#barDemo"}
				    ]]
				  });
				  
				  table.on('checkbox(employeeInfo)', function(obj){
						
				  });
				  
				  table.on('tool(employeeInfo)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
					  var data = obj.data; //获得当前行数据
					  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
					  var tr = obj.tr; //获得当前行 tr 的DOM对象
					 
					  if(layEvent === 'detail'){ //查看
					    //do somehing
					    //alert('ready to check detail :' + JSON.stringify(obj))
					  } else if(layEvent === 'del'){ //删除
					     layer.confirm('真的删除[' + obj.data.EmployeeName + ']吗', function(index){
					      obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
					      layer.close(index);
					      //向服务端发送删除指令
					      //alert('ready to delete :' + JSON.stringify(obj))
					      deleteEmployeeById(obj.data.EmployeeInfoId)
					    });
					  } else if(layEvent === 'edit'){ //编辑
					    //do something
					    //alert('ready to modify :' + JSON.stringify(obj))
					    layer.open({
							type : 2,
							title : '角色修改',
							maxmin : true,
							shadeClose : true, // 点击遮罩关闭层
							area : [ '800px', '520px' ],
							content : prefix + '/edit/' + obj.data.EmployeeInfoId // iframe的url
						});
					    //同步更新缓存对应的值
					    obj.update({
					      username: '123'
					      ,title: 'xxx'
					    });
					  }
					});
				  
				});
			
				
			
		}
		
		function clearCondition(){
			$("input#cmpName").val("")
			$("input#certNo").val("")
			$("input#bankCardNbr").val("")
			$("input#mobile").val("")
			$("input#abbrevation").val("")
			$("input#empStatus").val("")
		}
			
		function searchEmployee() {
			// alert('ready to search')
			clearEmployeesTable()
			loadEmployeesTable()
		}
		
		function deleteEmployeesWarn(){
			selectedEmployeeInfos = layui.table.checkStatus('EmployeesTable');
			// alert('selected:' + JSON.stringify(selectedEmployeeInfos))
			if( selectedEmployeeInfos.data.length == 0 ) {
				alert('none is selected')
				return
			}
			layer.confirm('真的删除选中的' + selectedEmployeeInfos.data.length + '行数据吗', function(index){
				deleteEmployees()
			    });
		}
		
		function deleteEmployees() {

				selectedEmployeeInfos = layui.table.checkStatus('EmployeesTable');
				// alert('selected:' + JSON.stringify(selectedEmployeeInfos))
				if( selectedEmployeeInfos.data.length == 0 ) {
					alert('none is selected')
					return
				}
				var idList = new Array()
				selectedEmployeeInfos.data.forEach(function(value,index,array){
					 
				idList.push(array[index].EmployeeInfoId)
				 
				});
				$.ajax({
					cache : false,
					type : "POST",
					url : prefix + "/batchDeleteEmployeeInfo",
					data : {EmployeeIdList : JSON.stringify(idList)}, // 你的formid
					async : false,
					error : function(request) {
						alert("Connection error");
					},
					success : function(r) {
						if (r.code == 0) {
							layer.msg("delete " + idList.length + " pieces succ");
							searchEmployee()
/* 							parent.reLoad();
							var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
							parent.layer.close(index); */

						} else {
							layer.msg(r.msg);
						}

					}
				});

		}
		
		function deleteEmployeeById(EmployeeId) {

			$.ajax({
				cache : false,
				type : "POST",
				url : prefix + "/deleteEmployeeInfo/" + EmployeeId,
				data : {}, // 你的formid
				async : false,
				error : function(request) {
					alert("Connection error");
				},
				success : function(r) {
					if (r.code == 0) {
						layer.msg("delete succ");
/* 						parent.reLoad();
						var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
						parent.layer.close(index); */

					} else {
						layer.msg(r.msg);
					}

				}
			});

	}
		
		
		function clearEmployeesTable() {
			let tableSet = document.getElementById("employeesTableSet")
			
			var childs = tableSet.childNodes;
			
			console.log('tableSet.childNodes length:' + childs.length)
			

			childs.forEach(function(value,index,array){
				tableSet.removeChild(array[index])
    		});
			
			tableSet.removeChild(tableSet.firstChild)

			var para=document.createElement("table");
			para.setAttribute("id", "employeesTable")
			para.setAttribute("lay-filter", "employeesInfo")
			tableSet.appendChild(para)

		}
		
		function addEmployee() {
			// iframe层
			layer.open({
				type : 2,
				title : '添加福利卡',
				maxmin : true,
				shadeClose : false, // 点击遮罩关闭层
				area : [ '800px', '520px' ],
				content : prefix + '/addEmployee' // iframe的url
			});
		}
			layui.use('laydate', function(){
				var laydate = layui.laydate;
				//执行一个laydate实例
				laydate.render({
					elem: '#date' //指定元素
				});
			});
